package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.entity.Result;
import com.itheima.pojo.Menu;
import com.itheima.service.TestUserService;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {
    @Reference
    TestUserService testUserService;

    @RequestMapping("/getUserName")
    public Result getUserName(){

//        org.springframework.security.core.userdetails.User user =
//                (org.springframework.security.core.userdetails.User)SecurityContextHolder.getContext().getAuthentication().getPrincipal();

        return Result.success("", "");

    }

    @RequestMapping("/findAllMenu")
    public Result findAllMenu(){
        List<Menu> menus = testUserService.findAllMenu();
        return Result.success("",menus);
    }
}
